From 38a74c7c789f41bdbbd759bf5809f379cc45578c Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Fri, 1 Feb 2013 21:17:02 -0500 Subject: [PATCH] (bug 25592) LogEventsList:showLogExtract should ignore WebRequest LogEventsList:showLogExtract currently pays attention to WebRequest parameters such as offset, dir, order, and limit (although limit is typically overridden by callers, and offset sometimes too). While these make sense for a pager that is driving the whole page, it doesn't make much sense for the "most recent log entry" boxes that are displayed using LogEventsList:showLogExtract. So let's have LogEventsList:showLogExtract ignore these, and for good measure add in a parameter to use the old behavior in case any caller really needs that. Change-Id: Id4380cd863ba69fc9b9afb5a0034d82ad4d9cc34 --- RELEASE-NOTES-1.22 | 4 ++++ includes/logging/LogEventsList.php | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 13a3c3cec2..cf31e5132a 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -31,6 +31,10 @@ production. by adding a new configuration variable $wgApplyIpBlocksToXff (disabled by default). * The new hook 'APIGetPossibleErrors' to modify the list of possible errors was added. +* (bug 25592) LogEventsList::showLogExtract() will now ignore various + Pager-related WebRequest parameters by default, as this is overwhelmingly + likely to be what was intended by users of the method. If any caller wishes + to use these parameters, the new param 'useRequestParams' may be set to true. === Bug fixes in 1.22 === * Disable Special:PasswordReset when $wgEnableEmail. Previously one could still diff --git a/includes/logging/LogEventsList.php b/includes/logging/LogEventsList.php index ba48bd72e0..7025332a50 100644 --- a/includes/logging/LogEventsList.php +++ b/includes/logging/LogEventsList.php @@ -464,6 +464,7 @@ class LogEventsList extends ContextSource { * set to '' to unset offset * - wrap String Wrap the message in html (usually something like "
$1
"). * - flags Integer display flags (NO_ACTION_LINK,NO_EXTRA_USER_LINKS) + * - useRequestParams boolean Set true to use Pager-related parameters in the WebRequest * @return Integer Number of total log items (not limited by $lim) */ public static function showLogExtract( @@ -475,7 +476,8 @@ class LogEventsList extends ContextSource { 'showIfEmpty' => true, 'msgKey' => array( '' ), 'wrap' => "$1", - 'flags' => 0 + 'flags' => 0, + 'useRequestParams' => false, ); # The + operator appends elements of remaining keys from the right # handed array to the left handed, whereas duplicated keys are NOT overwritten. @@ -487,6 +489,7 @@ class LogEventsList extends ContextSource { $msgKey = $param['msgKey']; $wrap = $param['wrap']; $flags = $param['flags']; + $useRequestParams = $param['useRequestParams']; if ( !is_array( $msgKey ) ) { $msgKey = array( $msgKey ); } @@ -500,6 +503,13 @@ class LogEventsList extends ContextSource { # Insert list of top 50 (or top $lim) items $loglist = new LogEventsList( $context, null, $flags ); $pager = new LogPager( $loglist, $types, $user, $page, '', $conds ); + if ( !$useRequestParams ) { + # Reset vars that may have been taken from the request + $pager->mLimit = 50; + $pager->mDefaultLimit = 50; + $pager->mOffset = ""; + $pager->mIsBackwards = false; + } if ( isset( $param['offset'] ) ) { # Tell pager to ignore WebRequest offset $pager->setOffset( $param['offset'] ); } -- 2.20.1